<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Session;

class Login extends Controller
{
    public function login()
    {
        if (isset($_POST['onsubmit'])) {
            $username = input('param.username');
            $pwd = input('param.pwd');
            //$pwd = md5($pwd);
            $admin = Db::table('sys_admin')->where(['username' => $username, 'pwd' => $pwd])->find();
            if ($admin) {
                Session::set('username', '$username');
                $this->redirect('/admin');
            } else {
                $this->error('登陆失败');
            }
        }
        return $this->fetch();
    }
}